axios.defaults.baseURL = 'http://124.223.14.236:8060/admin'
axios.interceptors.request.use(config => {
  if (config.url.indexOf('/ydd') !== -1) { //indexof 来判断（）内的内容出现在第几个下标 ，-1是指没有
    config.headers['x-token'] = localStorage.getItem('token')
  }

  return config;
}, error => {
  return Promise.reject(error);
});
// 响应拦截器 响应时若身份没有认证成功跳转到登录页面
axios.interceptors.response.use(response => {
  console.log(response);
  if (response.data.status === 1 && response.data.message === '身份认证失败！') {
    location.href = '/youdianda_static/index.html'
  }
  return response;
}, error => {
  return Promise.reject(error);
});
